package com.chennan.springsource.lifecycle.lifebean;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.*;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;

/**
 * @author chennan
 * @createTime 2022年03月22日 14:13:00
 */

//@Service
public class MySpringInit implements InitializingBean , BeanNameAware, BeanFactoryAware, ApplicationContextAware , DisposableBean {

    private String name;

    public MySpringInit() {
        System.out.println("执行 account 构造方法");
    }

    public void setName(String name) {
        this.name = name;
        System.out.println("执行===>setName方法");
    }

    public String getName() {
        return name;
    }


    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("执行 InitializingBean");
    }

    @PostConstruct
    public void iniitt(){
        System.out.println("执行  PostConstruct");
    }

    public void init(){
        System.out.println("执行 init 方法");
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        System.out.println("执行 BeanFactoryAware");
    }

    @Override
    public void setBeanName(String s) {

        System.out.println("执行 BeanNameAware");

    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        System.out.println("执行 ApplicationContextAware");

    }

    @Override
    public void destroy() throws Exception {
        System.out.println("执行 destroyBean方法");
    }

    public void destoryMothed(){
        System.out.println("执行 destoryMothed 方法");
    }
}



